<?php
session_start();
include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );

//从POST过来的signed_request中提取oauth2信息
if(!empty($_REQUEST["signed_request"])){
	$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY  );
	$data=$o->parseSignedRequest($_REQUEST["signed_request"]);
	if($data=='-2'){
		 die('签名 错误!');
	}else{
		$_SESSION['oauth2']=$data;
	}
}


//判断用户是否授权
if (empty($_SESSION['oauth2']["user_id"])) {//若没有获取到access token，则发起授权请求
		include_once( 'auth.php' );
		exit;
} else {//若已获取到access token，则加载应用信息
		$c = new SaeTClientV2( WB_AKEY , WB_SKEY ,$_SESSION['oauth2']['oauth_token'] ,'' );
	   // $c->update("test jokemall!");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="笑话超市" />
<meta name="description" content="笑话超市" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>笑话超市</title>
<script>
    if (window == top){
	 //alert("你不在框框里！！");
	 top.location.href = "http://apps.weibo.com/jokemall";  
	}  
</script>
</head>
<style>
body{
	background:url(img/fullbg03.png);
}
Div.Transp { /* Make The Div Translucent */
Opacity: 0.7;                 /* Firefox, Safari(WebKit), Opera)
Filter: "Alpha(Opacity=70)"; /* IE 8 */
Filter: Alpha(Opacity=70);   /* IE 4-7 */
Zoom: 1;                     /* Needed In IE Up To Version 7, Or Set Width Or Height To Trigger "HasLayout" */ 
}

Div.Transp80 { /* Make The Div Translucent */
Opacity: 0.9;                 /* Firefox, Safari(WebKit), Opera)
Filter: "Alpha(Opacity=90)"; /* IE 8 */
Filter: Alpha(Opacity=90);   /* IE 4-7 */
Zoom: 1;                     /* Needed In IE Up To Version 7, Or Set Width Or Height To Trigger "HasLayout" */ 
}


.jokeContainer{background-image:url(img/jokebg-repeater.png); width:647px; height:700px; margin:0 auto; margin-top:30px; overflow:visible;}
.jokeContent{float:left;  background-color:#FFF; width:460px;}
.joke{width:607px; margin-bottom:20px; }
.m10{margin:10px;}
.sharebtn{float:left; margin-left:20px; cursor:pointer;}
.clear{clear:both;}
</style>
<script src="http://tjs.sjs.sinajs.cn/t35/apps/opent/js/frames/client.js" language="JavaScript"></script>
<script src="jquery-1.8.2.min.js" language="javascript"></script>
<body style="margin:0; padding:0;">

<div id="wrapper" style=" width:760px; margin:0 auto;">
    <div class="Transp80"><img src="img/topbg.png" /></div>
 
	<div class="jokeContainer Transp">
        <img src="img/jokebg-top.png"/>
        <div style="margin:20px;">
        
        <?
        $mysql = new SaeMysql();
		$sql = "SELECT * FROM `joke` order by id desc LIMIT 6 ";
		$data = $mysql->getData( $sql );
		foreach ($data as $row) {
			?>
            <div class="joke">
            		<div  class="jokeContent">
           				 <div class="m10"><?=$row['jokecontent']?> </div>
      			  </div>
                   <div class="sharebtn"  jid="<?=$row['id']?>"><img src="img/publish_button_24.gif" title="" alt="" border="0"/></div>
                   <div class="clear"></div>
            </div>
            
            
            <?
		}
		
		$mysql->closeDb();
		?>
        	
          
            	
        </div>
        
    </div>
   <div style="clear:both;"></div>
   <div style=" text-align:center; color:#FFF; background-color:#06C; width:200px; margin:20px auto; padding:10px;">快乐不透支，明天再来呗！</div>
</div>
<script>


	$(".sharebtn").each(function(){
			$(this).click(function(){
				//图标变成 转
				$(this).html('<img src="img/ajaxwait.gif"/>');
				//成功变成 
				//alert($(this).attr("jid"));
				//alert($(this).parent().find('.jokeContent .m10').html());
				var tmp=this;
				$.post("public.php", { jokecontent: $(this).parent().find('.jokeContent .m10').html(), id: $(this).attr("jid") },
					   function(data) {
						// alert("Data Loaded: " + data);
						 var re=eval('(' + data + ')');
						 //alert(re.code);
						 if(re.code==1){
							 	$(tmp).html('<img src="img/ok.png"/>');
							 }else{
								 $(tmp).html('<img src="img/err.png"/>');
								 }
					   });
				});
		});

</script>

    <div style="display:none">
    <script language="javascript" type="text/javascript" src="http://js.users.51.la/14978403.js"></script>
<noscript><a href="http://www.51.la/?14978403" target="_blank"><img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/14978403.asp" style="border:none" /></a></noscript>
    </div>
	
</body>
</html>
